def delete_picture(file):
    """
    检测图片的类型
    :param file: 路径
    :return:
    """
    # 读取前 32 个字节
    data = open(file, "rb").read(32)

    if data[6:10] in (b'JFIF', b'Exif'):
        return 'jpeg'

    elif data.startswith(b'\211PNG\r\n\032\n'):
        return 'png'

    elif data[:6] in (b'GIF87a', b'GIF89a'):
        return 'gif'

    elif data[:2] in (b'MM', b'II'):
        return 'tiff'

    elif data.startswith(b'\001\332'):
        return 'rgb'

    elif len(data) >= 3 and data[0] == ord(b'P') and data[1] in b'14' and data[2] in b' \t\n\r':
        return 'pbm'

    elif len(data) >= 3 and data[0] == ord(b'P') and data[1] in b'25' and data[2] in b' \t\n\r':
        return 'pgm'

    elif len(data) >= 3 and data[0] == ord(b'P') and data[1] in b'36' and data[2] in b' \t\n\r':
        return 'ppm'

    elif data.startswith(b'\x59\xA6\x6A\x95'):
        return 'rast'

    elif data.startswith(b'#define '):
        return 'xbm'

    elif data.startswith(b'BM'):
        return 'bmp'

    elif data.startswith(b'RIFF') and data[8:12] == b'WEBP':
        return 'webp'

    elif data.startswith(b'\x76\x2f\x31\x01'):
        return 'exr'

    else:
        return None

